
package com.akupilih.app;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.MenuItem;
import android.widget.ImageView;

import com.akupilih.app.adapter.IndividuAdapter;
import com.akupilih.app.helper.PagerSlidingTabStrip;

public class IndividuActivity extends BaseActivity {
    private ViewPager mViewPager;
    private PagerSlidingTabStrip tabs;
    private ImageView profile;
    IndividuAdapter titleAdapter;
    public IndividuActivity() {
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_individu);
        getActionBar().setDisplayHomeAsUpEnabled(true);

        Bundle b = getIntent().getExtras();
        String kode = b.getString("kode");
        int value = b.getInt("key");

        profile = (ImageView) this
                .findViewById(R.id.activity_individu_profile);
        if (kode.equals("ps_hr")) {
            if (value == 1) {
                setTitle("Prabowo Subianto");
                profile.setBackgroundResource(R.drawable.profile_prabowo);
                titleAdapter = new IndividuAdapter(
                        getSupportFragmentManager(), "ps");
            } else {
                setTitle("Hatta Rajasa");
                profile.setBackgroundResource(R.drawable.profile_hatta);
                titleAdapter = new IndividuAdapter(
                        getSupportFragmentManager(), "hr");
            }
        } else {
            if (value == 1) {
                setTitle("Joko Widodo");
                profile.setBackgroundResource(R.drawable.profile_jokowi);
                titleAdapter = new IndividuAdapter(
                        getSupportFragmentManager(), "jw");
            } else {
                setTitle("Jusuf Kalla");
                profile.setBackgroundResource(R.drawable.profile_jk);
                titleAdapter = new IndividuAdapter(
                        getSupportFragmentManager(), "jk");
            }
        }

       

        /** Defining a listener for pageChange */
        ViewPager.SimpleOnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                super.onPageSelected(position);
            }
        };

        mViewPager = (ViewPager) findViewById(R.id.viewpager);
        tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
        mViewPager.setAdapter(titleAdapter);
        mViewPager.setCurrentItem(0);
        mViewPager.setOnPageChangeListener(pageChangeListener);
        tabs.setViewPager(mViewPager);
        tabs.setOnPageChangeListener(pageChangeListener);
        tabs.setIndicatorColor(Color.parseColor("#CC0000"));
        tabs.setIndicatorHeight(3);

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // TODO Auto-generated method stub
        if (item.getItemId() == android.R.id.home) {
            finish();
        }
        return true;
    }
}
